//
//  NetworkManager.h
//  Podcopter
//
//  Created by Ben Gotow on 2/4/10.
//

#import <Foundation/Foundation.h>
#import "GameClient.h"
#import "GameServer.h"
#import "NetUtilities.h"
#import "NetReachability.h"

#define kGameIdentifier                 @"Podcopter"
#define kServerPort                     12304


@interface NetworkManager : NSObject <GameServerDelegate, GameClientDelegate, NetReachabilityDelegate>{

    GameServer                          * server;
    BOOL                                  serverOn;
    BOOL                                  automaticallyReenableServer;
    
    GameClient                          * client;
    BOOL                                  clientOn;
    BOOL                                  automaticallyReenableClient;

    NSMutableDictionary                 * visibleServers;
    
    id                                    plist;
    NSString                            * name;
    NetReachability                     * reachability;
}

+ (NetworkManager*)sharedManager;
+ (id)allocWithZone:(NSZone *)zone;
- (id)copyWithZone:(NSZone *)zone;
- (id)retain;
- (unsigned)retainCount;
- (void)release;
- (id)autorelease;

- (NSString*)networkName;
- (id)networkPlist;

- (NSArray*)visibleServersArray;

#pragma mark Turning it on!

- (void)startClientSearch;
- (void)startServer;
- (void)commitNetworkingDisable;

#pragma mark Game Client Delegate Functions

- (void) gameClientDidStartDiscoveringServers:(GameClient*)c;
- (void) gameClientDidUpdateOnlineServers:(GameClient*)c;
- (void) gameClientWillStopDiscoveringServers:(GameClient*)c;

#pragma mark Game Server Delegate Functions

- (void) gameServer:(GameServer*)server gamePeerDidConnect:(GamePeer*)peer;
- (void) gameServerDidStartAdvertisingToClients:(GameServer*)server;
- (void) gameServerWillStopAdvertisingToClients:(GameServer*)server;

@end
